<?php defined('IN_LK') or die('Access Denied');?>
<?php include self::admin_t('header', 'admin');?>
<script type="text/javascript" src="<?php echo JS_PATH . 'colorpicker.js';?>"></script>
<script type="text/javascript" src="<?php echo JS_PATH . 'strlen_verfiy.js';?>"></script>

<form action="?m=admin&c=content_manage&a=add" method="post" id="myform">
  <dl class="form_list" style="position:relative">
    <fieldset>
      <legend>常规信息</legend>
      <dd><span class="w15 left">栏目</span>&nbsp;<strong><?php echo $catinfo['catname'];?></strong></dd>
      <dd><span class="left w15">信息标题</span>
        <input type="text" class="input" name="info[title]" id="title" style="width:300px" value="" onkeyup="strlen_verify(this, 'check', 80);" />
        <input type="hidden" name="info[color]" value="" />
        <input type="hidden" name="info[weight]" value="" />
        <span id="colorpicker" title="变色" onclick="colorpicker('title_colorpanel','set_title_color');">&nbsp;</span> <span class="colorpanel" style="position:absolute;z-index:99" id="title_colorpanel"></span> <span class="fontweight" title="加粗">&nbsp;</span> 还可以输入<strong id="check">80</strong>个字符 </dd>
      <dd><span class="left w15">自定义属性</span>
	  <?php foreach($pos as $p){?>
        <input type="checkbox" name="info[posid][]" id="posid<?php echo $p['posid']?>" value="<?php echo $p['posid']?>" />
        <label for="posid<?php echo $p['posid']?>"><?php echo $p['name'];?></label>
	  <?php }?>
      </dd>
      <dd><span class="left w15">缩略图</span>
        <input type="text" class="input" name="info[thumb]" id="thumb" size="1" />
      </dd>
      <dd><span class="left w15">科目</span>
      	<select id="objecttype" name="info[objecttype]">
          <?php foreach($objs as $k => $val){?>
          <option value="<?php echo $k;?>"><?php echo $val?></option>
          <?php }?>
      	</select>
      </dd>
      <dd><span class="left w15">培训方式</span>
      <?php foreach($pxfs as $pk => $pv){?>
      <input type="radio" name="info[pxfangshi]" id="px<?php echo $pk?>" value="<?php echo $pk?>" />&nbsp;<label for="px<?php echo $pk?>"><?php echo $pv?></label>
      <?php }?>
      </dd>
      <dd><span class="left w15">信息内容</span>
        <textarea name="info[content]" id="content" cols="70" rows="5"></textarea>
      </dd>
      <dd><span class="left w15">发布时间</span>
        <?php echo form::input_date('info[inputtime]', date('Y-m-d H:i:s', TIME));?> 
      </dd>
      <dd><span class="left w15">价格</span>
        <input type="text" class="input" name="info[price]" id="price" size="10" value="0" />元
      </dd>
      <dd><span class="left w15">联系人</span>
        <input type="text" class="input" name="info[c][man]" id="cman" size="25" value="" />
      </dd>
      <dd><span class="left w15">联系电话</span>
      	<input type="text" class="input" name="info[c][tel]" id="tel" size="25" value="" />
      </dd>
      <dd><span class="left w15">电子邮箱</span>
        <input type="text" class="input" name="info[c][email]" id="email" size="36" value="" />
      </dd>
      <dd><span class="left w15">地址</span>
        <input type="text" class="input" name="info[c][addr]" id="addr" size="50" value="" />
      </dd>
    </fieldset>
    <fieldset>
    	<legend>高级选项</legend>
        <dd><span class="left w15">置顶</span>
        	<input type="text" class="input" name="info[listorder]" id="listorder" size="3" value="999" /> 
        </dd>
        <dd><span class="left w15">允许评论</span>
        <input type="radio" name="info[allow_comment]" id="allow_commnet1" value="1" /><label for="allow_commnet1">允许</label>
        <input type="radio" name="info[allow_comment]" id="allow_commnet0" checked="checked" value="0" /><label for="allow_commnet0">不允许</label>
        </dd>
    </fieldset>
    <input class="none" type="submit" id="dosubmit" name="dosubmit" value="提交" />
    <input type="hidden" name="info[catid]" value="<?php echo $catid;?>" />
  </dl>
</form>
<form target="fileframe" action="?m=api&a=upload" method="post" enctype="multipart/form-data" style="position:absolute;left:144px;top:159px;*left:146px;*top:161px">
  <input type="hidden" name="catid" value="1" />
  <input type="text" class="input" name="thumb" id="thumbs" size="35" value="" style="cursor:default" />
  <input type="file" name="filedata" id="filedata" style="cursor:default;position:absolute;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;" size="1" />
  <input type="submit" class="btn" name="doupload" id="doupload" value="上传" />
  <span id="showimg">支持格式<strong> jpg、jpeg、gif、png、bmp </strong></span>
</form>
<div  style="display:none"><iframe name="fileframe"></iframe></div>
</body></html><script type="text/javascript">
<!--
$(function()
{
	$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
	$('#title').formValidator({'onfocus':'请输入标题', 'onshow':'请输入标题', 'oncorrect':'标题输入正确'}).inputValidator({min:2, onerror:'标题不能为空'});
	$('input[name="info[pxfangshi]"]').formValidator({onshow:'请选择培训方式', onfocus:'请选择培训方式'}).inputValidator({min:1,onerror:"请至少选择一项"});
	$('#content').formValidator({'onfocus':'请输入内容', 'onshow':'请输入信息内容'}).inputValidator({min:1, onerror:'内容不能为空'});
	$('#price').formValidator({'onfocus':'请输入价格', 'onshow':'为空表示价格为面议', 'oncorrect':'为空表示价格为面议', empty:true}).regexValidator({regexp:"decmal4",datatype:"enum",onerror:"价格为只能为非负数"}).defaultPassed();
	$('#cman').formValidator({'onfocus':'请输入联系人', 'onshow':'请输入联系人'}).inputValidator({min:1, onerror:'联系人不能为空'}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"联系人格式错误"});
	$('#tel').formValidator({'onfocus':'请输入电话号码', 'onshow':'请输入电话号码'}).inputValidator({min:1, onerror:'电话号码不能为空'}).regexValidator({regexp:"^(1)[0-9]{9}|(([0\\+]\\d{2,3}-)?(0\\d{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$",onerror:"电话号码格式错误"});
	$('#email').formValidator({'onfocus':'请输入E-mail', 'onshow':'请输入E-mail', empty:true}).regexValidator({regexp:"email",datatype:"enum",onerror:"E-mail格式错误"}).defaultPassed();
	$('#addr').formValidator({'onfocus':'请输入联系地址', 'onshow':'请输入联系地址'}).inputValidator({min:1, onerror:'请联系地址不能为空'});
	$('#listorder').formValidator({'onfocus':'数字越小越置顶越有效', 'onshow':'数字越小越置顶越有效'}).inputValidator({min:1,max:3, onerror:'数字范围在1-3位'}).regexValidator({regexp:"num1",datatype:"enum",onerror:"请输入整数"});
});
$(function()
{
	$('#colorpicker').click(function(e)
	{
		var x = e.pageX, y = e.pageY;
		$('#title_colorpanel').css({'top':y + 5 + 'px', 'left' : x + 5 + 'px'});
	});
	$('.fontweight').toggle(function(){
		$('#title').css({'font-weight':'bold'});
		$('input[name="info[weight]"]').val('bold');
	}, function(){
		$('#title').css({'font-weight':'normal'});
		$('input[name="info[weight]"]').val('');
	});
	
	$('#thumbs').mousemove(function(e){
		var x = e.pageX, y = e.pageY;
		$('#filedata').css({'top':y - 165 + 'px', 'left':x - 180 +'px'});
	});
	$('#filedata').change(function(){
		$('#thumbs').val($(this).val());
	});
	$('#doupload').click(function(){
		if($('#filedata').val() == '')
		{
			alert('请选择文件再上传');
			return false;
		}
	});
});
function showimg(img)
{
	$('#showimg').addClass('green').html('上传成功&nbsp;' + '<img src="<?php echo UPLOAD_URL?>' + img + '" width="30" height="25" />');
	$('#filedata').val('');
	$('#thumbs').val(img);
	$('#thumb').val(img);
}
function set_title_color(color)
{
	$('#title').css({'color':color});
	$('input[name="info[color]"]').val(color);
}
// -->
</script>